<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>回调函数的练习</title>
</head>

<body>
    <p>要求：运算 (2+3)*4 的结果</p>
    <p>例一：函数 A执行函数B，函数B是回调函数。</p>
    <script>
        function A(x, y, z, m) {
            var re = x + y;
            return m(re, z);
        }
        function B(x, y) {
            return x * y;
        }
        document.write(A(2, 3, 4, B));
    </script>
    <p>例二：函数 b执行函数a，函数a是回调函数。</p>
    <script>
        function a(x, y) {
            return x + y;
        }
        function b(x, y, z, k) {
            var re = k(x, y);
            return re * z;
        }
        document.write(b(2, 3, 5, a));
    </script>
</body>

</html>